package org.web.base.helper;

import org.springframework.security.crypto.encrypt.Encryptors;
import org.springframework.security.crypto.encrypt.TextEncryptor;


public class CryptoHelper {

    private static final String PASSWORD = "your-password"; // 16位密码
    private static final String SALT = "1A2B3C"; // 16位盐值

    public static TextEncryptor textEncryptor = Encryptors.text(PASSWORD, SALT);

    /**
     * 加密方法
     */
    public static String encrypt(String data) {
        return textEncryptor.encrypt(data);
    }

    /**
     * 解密方法
     */
    public static String decrypt(String encryptedData) {
        return textEncryptor.decrypt(encryptedData);
    }

}
